package com.jsoft.service;

import com.jsoft.dto.DiscountDto;
import com.jsoft.manager.DiscountManager;
import com.jsoft.model.DiscountMarginDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;

/**
 * Date: 22.08.13
 * Time: 18:08
 */

@Service
public class DiscountServiceImpl implements DiscountService {
    @Autowired
    private DiscountManager discountManager;

    @Override
    @Transactional(readOnly = true)
    public List<DiscountDto> getDiscountList() {
        List<DiscountMarginDao> discountDaoList = discountManager.getAllList();
        List<DiscountDto> discountDtoList = new ArrayList<DiscountDto>();
        for (DiscountMarginDao dao : discountDaoList) {
            discountDtoList.add(dao.wrapDiscountDto());
        }
        return discountDtoList;
    }
}
